获取当前ip 和位置
<script type="text/javascript">
var url = 'http://chaxun.1616.net/s.php?type=ip&output=json&callback=?&_=' + Math.random();
$.getJSON(url, function(data) {
alert(data.Ip); //当前ip
var url2 = "http://ip.taobao.com/service/getIpInfo.php?ip=" + data.Ip;
$.getJSON(url, function(josn) {
console.log(josn);
});
});
</script>
<script type="text/javascript">
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(_result) {
if (remote_ip_info.ret == '1') {
alert('国家:' + remote_ip_info.country + '<BR>省:' + remote_ip_info.province + '<BR>市:' + remote_ip_info.city + '<BR>区:' + remote_ip_info.district + '<BR>ISP:' + remote_ip_info.isp + '<BR>类型:' + remote_ip_info.type + '<BR>其他:' + remote_ip_info.desc);
} else {
alert('没有找到匹配的IP地址信息!');
}
});
</script>